Attribute VB_Name = "SettingsHelper"
Option Explicit

'TODO: Insert standard header

Public Const MaximumShapesDisplayed_AutomaticValue As Byte = 0
Public Const MaximumShapesDisplayed_DefaultValue   As Byte = 0
Public Const MaximumShapesDisplayed_MaximumValue   As Byte = 240
Public Const MaximumShapesDisplayed_MinimumValue   As Byte = 0 ' Automatic
Public Const MaximumShapesDisplayed_SettingName    As String = "MaximumShapesDisplayed"

'#Region Public Methods

' Summary:
'   Parses and validates a value for the MaximumShapesDisplayed configuration
'   value.
' Params:
'   Value:
'     The value to parse/validate.
' Returns:
'   Valid value for the MaximumShapesDisplayed configuration value. Either
'   Value; or if this is not a valid value, the default value.
Public Function ParseMaximumShapesDisplayed(ByVal Value As String) As Byte
    Dim ParsedValue As Byte
    
    On Error GoTo UseDefaultValue
    
    ' Try to convert to the correct type
    ParsedValue = CByte(Value)
    
    ' Range check
    If ParsedValue < SettingsHelper.MaximumShapesDisplayed_MinimumValue Or _
       ParsedValue > SettingsHelper.MaximumShapesDisplayed_MaximumValue Then
        ' Outside the valid range - use default
        GoTo UseDefaultValue
    End If
    
    GoTo ReturnValue
    
UseDefaultValue:
    ParsedValue = SettingsHelper.MaximumShapesDisplayed_DefaultValue
    
ReturnValue:
    ParseMaximumShapesDisplayed = ParsedValue
End Function

'#End Region
